import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import { usePermissStore } from '../store/permiss';
import Home from '../views/home.vue';
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const routes: RouteRecordRaw[] = [
    {
        path: '/',
        redirect: '/tabs',
    },
    {
        path: '/',
        name: 'Home',
        component: Home,
        children: [
            {
                path: '/charts',
                name: 'basecharts',
                meta: {
                    title: '人员管理',
                    permiss: '11',
                },
                component: () => import(/* webpackChunkName: "charts" */ '../views/charts.vue'),
            },
            {
                path: '/voluneerManage',
                name: 'voluneerManage',
                meta: {
                    title: '志愿者管理',
                    permiss: '10',
                },
                component: () => import(/* webpackChunkName: "voluneer" */ '../views/tabs_voluneer.vue'),
            },
            // {
            // path: '/echarts',
            // name: 'baseecharts',
            // meta: {
            // title: '数据可视化',
            // permiss: '12',
            // },
            // component: () => import(/* webpackChunkName: "charts" */ '../views/echarts.vue'),
            // },
            {
                path: '/tabs',
                name: 'tabs',
                meta: {
                    title: '风采列表',
                    permiss: '3',
                },
                component: () => import(/* webpackChunkName: "tabs" */ '../views/tabs.vue'),
            },
            {
                path: '/tabs_gonggao',
                name: 'tabs_gonggao',
                meta: {
                    title: '公告列表',
                    permiss: '4',
                },
                component: () => import(/* webpackChunkName: "tabs" */ '../views/tabs_gonggao.vue'),
            },
            {
                path: '/tabs_lunbo',
                name: 'tabs_lunbo',
                meta: {
                    title: '轮播列表',
                    permiss: '5',
                },
                component: () => import(/* webpackChunkName: "tabs" */ '../views/tabs_lunbo.vue'),
            },
            {
                path: '/tabs_media',
                name: 'tabs_media',
                meta: {
                    title: '媒体列表',
                    permiss: '6',
                },
                component: () => import(/* webpackChunkName: "tabs" */ '../views/tabs_fengcai.vue'),
            },
            // {
                // path: '/kmeans',
                // name: 'kmeans',
                // meta: {
                    // title: '销售预测折线图',
                    // permiss: '5',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/kmeans.vue'),
            // },
            // {
                // path: '/ai',
                // name: 'ai',
                // meta: {
                    // title: 'AI智能回答',
                    // permiss: '7',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/Aianswer.vue'),
            // },
            // {
                // path: '/spiderCode',
                // name: 'spiderCode',
                // meta: {
                    // title: '代码展示',
                    // permiss: '8',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/code.vue'),
            // },
            // {
                // path: '/process',
                // name: 'process',
                // meta: {
                    // title: '数据预处理',
                    // permiss: '8',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/process.vue'),
            // },
            // {
                // path: '/codeProcess',
                // name: 'codeProcess',
                // meta: {
                    // title: '代码展示',
                    // permiss: '8',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/processCode.vue'),
            // },
            {
                path: '/startBar',
                name: 'startBar',
                meta: {
                    title: '数据分析可视化',
                    permiss: '8',
                },
                component: () => import(/* webpackChunkName: "tabs" */ '../views/startBar.vue'),
            },
            {
                path: '/tabs_feedBack',
                name: 'tabs_feedBack',
                meta: {
                    title: '反馈管理',
                    permiss: '9',
                },
                component: () => import(/* webpackChunkName: "tabs" */ '../views/tabs_feedBack.vue'),
            },
            // {
                // path: '/incomeHis',
                // name: 'incomeHis',
                // meta: {
                    // title: '电影票房分布分析',
                    // permiss: '8',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/incomeHis.vue'),
            // },
            // {
                // path: '/yearAna',
                // name: 'yearAna',
                // meta: {
                    // title: '电影发布年份分析',
                    // permiss: '8',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/yearAna.vue'),
            // },
            // {
                // path: '/actorAna',
                // name: 'actorAna',
                // meta: {
                    // title: '电影演员分析',
                    // permiss: '8',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/actorAna.vue'),
            // },
            // {
                // path: '/regionAna',
                // name: 'regionAna',
                // meta: {
                    // title: '电影出版地区分析',
                    // permiss: '8',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/regionAna.vue'),
            // },
            // {
                // path: '/directorAna',
                // name: 'directorAna',
                // meta: {
                    // title: '电影导演分析',
                    // permiss: '8',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/directorAna.vue'),
            // },
            // {
                // path: '/modelCode',
                // name: 'modelCode',
                // meta: {
                    // title: '代码展示',
                    // permiss: '8',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/modelCode.vue'),
            // },
            // {
                // path: '/modelAna',
                // name: 'modelAna',
                // meta: {
                    // title: '建模分析',
                    // permiss: '8',
                // },
                // component: () => import(/* webpackChunkName: "tabs" */ '../views/modelAna.vue'),
            // },
        ],
    },
    // {
    // path: '/login',
    // name: 'Login',
    // meta: {
    // title: '登录',
    // },
    // component: () => import(/* webpackChunkName: "login" */ '../views/login.vue'),
    // },
    // {
    // path: '/createLogin',
    // name: 'createLogin',
    // meta: {
    // title: '注册用户',
    // },
    // component: () => import(/* webpackChunkName: "createLogin" */ '../views/createLogin.vue'),
    // },
    {
        path: '/writeLogin',
        name: 'writeLogin',
        meta: {
            title: '修改密码',
        },
        component: () => import(/* webpackChunkName: "writeLogin" */ '../views/writeLogin.vue'),
    },
    {
        path: '/403',
        name: '403',
        meta: {
            title: '没有权限',
        },
        component: () => import(/* webpackChunkName: "403" */ '../views/testUpload.vue'),
    },

];

const router = createRouter({
    history: createWebHashHistory(),
    routes,
});

// router.beforeEach((to, from, next) => {
// NProgress.start();
// for (let i = 0; i < localStorage.length; i++) {
// const key = localStorage.key(i);
// if (key) {
// const value = localStorage.getItem(key);
// console.log(`${key}: ${value}`);
// }
// }
// const role = localStorage.getItem('ms_username');
// const permiss = usePermissStore();
// console.log("获取到的permiss"+role)
// console.log(permiss.key)
// console.log("权限赋值:")
// if (to.path === '/createLogin' || to.path === '/writeLogin') {
// next();
// } else if (!role && to.path !== '/login') {
// next('/login');
// } else if (to.meta.permiss && !permiss.key.includes(to.meta.permiss)) {
// 如果没有权限，则进入403
// next('/403');
// } else {
// next();
// }
// });

router.afterEach(() => {
    NProgress.done()
})

export default router;
